/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.elicitor.core;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

/**
 *
 * @author dileepa
 */
public class RBF {
    
    /*
        1.articulationrate
        2.pitchMinimum
        3.pitchMaximum
        4.pitchQ1
        5.pitchQ2
        6.pitchQ3
        7.pitchMean
        8.pitchStd
        9.jitter
        10.shimmer
        11.meanf1
        12.meanf2
        13.meanf3
        14.medianf1
        15.medianf2
        16.medianf3
        17.stdevf1
        18.stdevf2
        19.stdevf3
        20.meanspl
        21.medianspl
        22.stdspl
        23.minspl
        24.maxspl
     
     */
    
        List <Double> articulationrate = new ArrayList<Double>(); 
        List <Double> pitchMinimum = new ArrayList<Double>(); 
        List <Double> pitchMaximum = new ArrayList<Double>(); 
        List <Double> pitchQ1 = new ArrayList<Double>(); 
        List <Double> pitchQ2 = new ArrayList<Double>(); 
        List <Double> pitchQ3 = new ArrayList<Double>(); 
        List <Double> pitchMean = new ArrayList<Double>(); 
        List <Double> pitchStd = new ArrayList<Double>(); 
        List <Double> jitter = new ArrayList<Double>(); 
        List <Double> shimmer = new ArrayList<Double>(); 
        List <Double> meanf1 = new ArrayList<Double>(); 
        List <Double> meanf2 = new ArrayList<Double>(); 
        List <Double> meanf3 = new ArrayList<Double>(); 
        List <Double> medianf1 = new ArrayList<Double>(); 
        List <Double> medianf2 = new ArrayList<Double>(); 
        List <Double> medianf3 = new ArrayList<Double>(); 
        List <Double> stdevf1 = new ArrayList<Double>(); 
        List <Double> stdevf2 = new ArrayList<Double>(); 
        List <Double> stdevf3 = new ArrayList<Double>(); 
        List <Double> meanspl = new ArrayList<Double>(); 
        List <Double> medianspl = new ArrayList<Double>(); 
        List <Double> stdspl = new ArrayList<Double>(); 
        List <Double> minspl = new ArrayList<Double>(); 
        List <Double> maxspl = new ArrayList<Double>(); 
    
    public void storeAttributes(){
         
        Scanner scanner = null;
        
        File file = new File("/home/dileepa/Documents/testValues/emotionTraingNew.csv");
 
        try {
 
             scanner = new Scanner(file);
            while (scanner.hasNextLine()) {
                String line = scanner.nextLine();
                String result[] = line.split(",");
        if(result.length == 24){  
            
        articulationrate.add(Double.parseDouble(result[0]));
        pitchMinimum.add(Double.parseDouble(result[1]));
        pitchMaximum.add(Double.parseDouble(result[2]));
        pitchQ1.add(Double.parseDouble(result[3]));
        pitchQ2.add(Double.parseDouble(result[4]));
        pitchQ3.add(Double.parseDouble(result[5]));
        pitchMean.add(Double.parseDouble(result[6]));
        pitchStd.add(Double.parseDouble(result[7]));
        jitter.add(Double.parseDouble(result[8]));
        shimmer.add(Double.parseDouble(result[9]));
        meanf1.add(Double.parseDouble(result[10]));
        meanf2.add(Double.parseDouble(result[11]));
        meanf3.add(Double.parseDouble(result[12]));
        medianf1.add(Double.parseDouble(result[13]));
        medianf2.add(Double.parseDouble(result[14]));
        medianf3.add(Double.parseDouble(result[15]));
        stdevf1.add(Double.parseDouble(result[16]));
        stdevf2.add(Double.parseDouble(result[17]));
        stdevf3.add(Double.parseDouble(result[18]));
        meanspl.add(Double.parseDouble(result[19]));
        medianspl.add(Double.parseDouble(result[20]));
        stdspl.add(Double.parseDouble(result[21]));
        minspl.add(Double.parseDouble(result[22]));
        maxspl.add(Double.parseDouble(result[23]));
       
        }
            }
         
        
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        finally{
            scanner.close();
        }
        
    }
    
    
        
        
    
        
    public static void main(String[] args) {
        
        RBF rbf = new RBF();
        rbf.storeAttributes();
        rbf.applyRBF();
        
        
    }

    private void applyRBF() {
        
        
             PrintStream out = null;
        
try {
    out = new PrintStream(new FileOutputStream("RBF/mediansplPitchMini.csv"));
    out.println("y1,Emotion"); 
    for (int i=0;i<155;i++){
       out.println(medianspl.get(i)*pitchMinimum.get(i)*meanspl.get(i)*maxspl.get(i)+",Anger"); 
    }
    for (int i=155;i<310;i++){
       out.println(medianspl.get(i)*pitchMinimum.get(i)*meanspl.get(i)*maxspl.get(i)+",Disgust"); 
    }
    for (int i=310;i<465;i++){
       out.println(medianspl.get(i)*pitchMinimum.get(i)*meanspl.get(i)*maxspl.get(i)+",Fear"); 
    }
    for (int i=465;i<620;i++){
       out.println(medianspl.get(i)*pitchMinimum.get(i)*meanspl.get(i)*maxspl.get(i)+",Happy"); 
    }
    for (int i=620;i<775;i++){
       out.println(medianspl.get(i)*pitchMinimum.get(i)*meanspl.get(i)*maxspl.get(i)+",Sadness"); 
    }
    for (int i=775;i<930;i++){
       out.println(medianspl.get(i)*pitchMinimum.get(i)*meanspl.get(i)*maxspl.get(i)+",Surprise"); 
    }
    
    
}catch(Exception e){
    System.err.println("Errroer "+e.getMessage());
}
finally {
    if (out != null) out.close();
}

    
    
    }
    
}
